package com.hjy.elasticsearch.controller;

import com.hjy.elasticsearch.service.MyESService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @CopyRight: 版权所有
 * @Author: hejinyi
 * @Description:
 * @Date: 2020/12/1
 */
@Controller
@RequestMapping("/myES")
public class MyController {

    private static final Logger LOGGER = LoggerFactory.getLogger(MyController.class);

    @Autowired
    private MyESService myESService;

//    @RequestMapping(value = "find",method = RequestMethod.POST)
//    @ResponseBody
//    public List find(String index, String msg, String tableName){
//        List list = myESService.mySearch(index,msg,tableName);
//        return list;
//    }
//
//    @RequestMapping(value = "findOrder",method = RequestMethod.POST)
//    @ResponseBody
//    public List findOrder(String index, String msg){
//        List list = myESService.mySearch(index,msg,null);
//        return list;
//    }

//    @RequestMapping(value = "findProduct",method = RequestMethod.POST)
//    @ResponseBody
//    public List findProduct(String searchTerm1,String searchContent1,String searchTerm2,String searchContent2){
//        List list = myESService.mySearch(searchTerm1,searchContent1,searchTerm2,searchContent2);
//        return list;
//    }

    /**
     *
     * @param searchContent
     * @param productType 1:景区 2:酒店 3:餐馆 4:特产 5:线路
     * @return
     */
    @RequestMapping(value = "findProduct",method = RequestMethod.POST)
    @ResponseBody
    public List findProduct(String searchContent,String productType){
        List list = myESService.seachBody(searchContent,productType);
        return list;
    }
}
